package com.springboot.training.designpatterns.decorator;

public class DecoratorTest {

    public static void testAnyThing(){
        AnyThing t = new Moon(new Dream(new You(null)));
        t.exe();
        //输出：明月装饰了梦装饰了你

        System.out.println();

        AnyThing t2 = new Dream(new Moon(new You(null)));
        t2.exe();
        //输出：梦装饰了明月装饰了你

        System.out.println();
    }

    public static void testMan(){
        //创建被装饰的类
        Human human = new Man();

        //创建装饰的类，并添加被装饰类的引用
        Human superMan = new ManDecorator(human);

        //执行增强后的run方法
        superMan.run();
    }


    public static void main(String[] args) {
        DecoratorTest.testAnyThing();

        System.out.println();

        DecoratorTest.testMan();
    }
}
